Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aggregator: unify resolver implementation and tests #46623

Merged

Conversation

sttts
Copy link
Contributor

@sttts sttts commented May 30, 2017

This is #45082, but without the port support.

@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. release-note-label-needed labels May 30, 2017
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 30, 2017
@sttts sttts force-pushed the sttts-aggregator-unified-modes branch from 5d2838e to 4ed36e9 Compare May 30, 2017 16:45
}

return svc, "https", "443", nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem like good defaults but if the service object already has the port and scheme, then either grab those and return them or just return the service and leave it to the caller to worry about extracting/determining defaults. (We already seem to handle the port portion of this in your findServicePort method) This also suggests we are dropping support for "HTTP" when talking to aggregated api servers. I think thats probably a good thing but I want to make sure its a deliberate choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code here from #45082, i.e. the caller decides.

The HTTP removal is intentional, as discussed in #45082 with @deads2k. For dev and testing one can disable cert verification and use self-signed certs. So we don't need HTTP anymore.

// Find a Subset that has the port.
for ssi := 0; ssi < len(eps.Subsets); ssi++ {
ss := &eps.Subsets[(ssSeed+ssi)%len(eps.Subsets)]
if len(ss.Addresses) == 0 {
continue
}
for i := range ss.Ports {
if ss.Ports[i].Name == portStr {
if ss.Ports[i].Name == svcPort.Name {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for now but there is something odd about the case where we are asked for a port number match, find the first matching port number and the pick all the routes which match that routes port name. If ports are consistently names there won't be an issue but if they aren't the behavior is going to be very hard to debug.

@sttts sttts force-pushed the sttts-aggregator-unified-modes branch 2 times, most recently from 6911648 to 96dba6a Compare May 31, 2017 06:37
@sttts
Copy link
Contributor Author

sttts commented May 31, 2017

@cheftako addressed your comments. Also removed the remaining forbidden import in the tests. Ready for final review.

@sttts sttts force-pushed the sttts-aggregator-unified-modes branch from 96dba6a to 869fab5 Compare May 31, 2017 06:53
@sttts sttts added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels May 31, 2017
@deads2k
Copy link
Contributor

deads2k commented May 31, 2017

lgtm
/approve

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 31, 2017
@deads2k
Copy link
Contributor

deads2k commented May 31, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 31, 2017
@sttts sttts added this to the v1.7 milestone May 31, 2017
}
return nil, errors.NewServiceUnavailable(fmt.Sprintf("no service port %q found for service %q", port.String(), svc.Name))
}

// ResourceLocation returns a URL to which one can send traffic for the specified service.
func ResolveEndpoint(services listersv1.ServiceLister, endpoints listersv1.EndpointsLister, namespace, id string) (*url.URL, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have change the meaning of the id field (it used to be scheme : service name : port) it is now just the service name. I believe the caller at either https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go#L153-L155 or https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_proxy.go#L116 will need to be fixed to reflect this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did. But I am struggling to find out where we decide/document that a service name (which comes from APIService as far as I see) can be in this colon syntax.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran your fix on my GCE cluster. Despite my worries looks like it works just fine.

@deads2k
Copy link
Contributor

deads2k commented May 31, 2017

You have change the meaning of the id field (it used to be scheme : service name : port) it is now just the service name. I believe the caller at either https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go#L153-L155 or https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_proxy.go#L116 will need to be fixed to reflect this.

The service name has always been intended to be just a name, all the way back to the initial comment from @lavalamp about doing so here back in november: #37561 (comment) .

If it changed, then it was an accidental quirk of implementation that change the API from its intended and documented shape. If we want a port, that port name or int should be structured in the API as such and not glommed as a string. And I was strongly swayed by Daniel's point in the initial version of the API.

@cheftako
Copy link
Member

/lgtm

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheftako, deads2k, sttts

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@sttts
Copy link
Contributor Author

sttts commented Jun 1, 2017

@k8s-bot pull-kubernetes-node-e2e test this
@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this
@k8s-bot pull-kubernetes-e2e-kops-aws test this
@k8s-bot pull-kubernetes-federation-e2e-gce test this

@sttts sttts force-pushed the sttts-aggregator-unified-modes branch from 869fab5 to c7d9a39 Compare June 1, 2017 07:26
@sttts sttts added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jun 1, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 43505, 45168, 46439, 46677, 46623)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants